<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" href="layui/css/public.css" media="all">
    <script type="text/javascript" src="layui/jquery.min.js"></script>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item" style="display: none">
        <label class="layui-form-label required">ID</label>
        <div class="layui-input-block">
            <input type="number" id="custId" name="custId" lay-verify="required"  class="layui-input">
<!--            lay-reqtext="手机不能为空" placeholder="请输入手机"-->
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="custName" id="custName" lay-verify="required" class="layui-input">
<!--            <tip>填写自己管理账号的名称。</tip>-->
        </div>
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label required">性别</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="radio" id="custSource" name="sex" value="男" title="男" checked="">-->
<!--            <input type="radio" name="sex" value="女" title="女">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label required">资源</label>
        <div class="layui-input-block">
            <input type="number" id="custSource" name="custSource"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">手机</label>
        <div class="layui-input-block">
            <input type="number" id="custPhone" name="custPhone"   class="layui-input">
        </div>
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">邮箱</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="email" name="email" placeholder="请输入邮箱" value="" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">工厂</label>
        <div class="layui-input-block">
            <input type="text" id="custIndustry" name="custIndustry"  class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">水平</label>
        <div class="layui-input-block">
            <input type="text" id="custLevel" name="custLevel"   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">住址</label>
        <div class="layui-input-block">
            <textarea name="custAddress" id="custAddress" class="layui-textarea" ></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="layui/layui.js" charset="utf-8"></script>
<script>

    $(function (){
        $.ajax({
            url: '/user/findByUser',
            type: 'post',
            success: function (data) {
                if (data.msg != 1) {
                    alert("您没有登录请重新登录");
                    window.self.location = "index.html";
                    // $.messager.alert({
                    //     title:'提示',
                    //     msg:'读取数据异常：'+map.msg
                    // });
                    return;
                }
            }
        })
    })

    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {
                // console.log(JSON.stringify(data.field));
                $.ajax({
                    url: 'dfq/update',
                    data: JSON.stringify(data.field),
                    contentType: "application/json;charset=utf-8",
                    dataType:'json',
                    type: "post",
                    async: false,//false为同步，这个Ajax请求将整个浏览器锁死
                    success:function (d){
                        if (d.msg==1){
                            alert("修改成功");
                             window.parent.location.reload();//修改成功后刷新父界面
                        }else {
                            alert(d.msg);
                        }
                    }
                })
                // 关闭弹出层
                layer.close(index);
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });

            return false;
        });

    });
</script>
</body>
</html>